<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <button id="btn" onclick="console.log('我可以运行哦~~')">测试</button>
  <div style="width: 200px;height: 200px;background:#eaf" onclick="callback(this)" onmouseover="this.style.background = 'black'"></div>
  <button id="btn2">测试事件对象</button>
  <input type="text" id="input">
  <script>
    function callback(target){
      target.style.background = 'yellowgreen';
    }

    //获取元素
    // let btn = document.querySelector('#btn');

    // //DOM 0 
    // btn.onclick = function(){
    //   console.log(111);
    // }

    // //DOM 2
    // btn.addEventListener('click', function(){
    //   console.log(222);
    // });

    //查看事件对象
    btn2.onclick = function(e){
      console.log(e);
    }

    //为 input 元素绑定 change 事件
    // input.onchange = function(){
    //   console.log('我的值改变啦~~');
    // }

    input.oninput = function(){
      console.log('输入了内容');
    }

  </script>
</body>
</html>